﻿Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Seuss.EnterpriseLibrary.DataAccess
Imports Seuss.EnterpriseLibrary.BusinessLogic
Imports System.Web
Imports System.Data

Partial Class Consulta_AD_Horario
    Inherits System.Web.UI.Page
    Dim cPerJuridica As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Expires = -1
        Response.AddHeader("Pragma", "no-cache")
        Response.AddHeader("cache-control", "private")
        Response.CacheControl = "no-cache"

        If Not Page.IsPostBack Then
            Call CargarHorario()
        End If
    End Sub

    Private Sub CargarHorario()
        Dim ldr As New List(Of IDataReader)
        Dim DivPrincipal As New StringBuilder
        Dim DivEscuela As New StringBuilder
        Dim Escuela As String = ""        

        DivPrincipal.Append("<table border=0 width='100%'>")

        Using ObjPool As New PoolDbCommand()
            Dim ObjUsuario As New DAL_Kiosco(ObjPool.Database)
            ObjPool.AddDbCommand(ObjUsuario.Get_HorarioAdministrativo_By_cPerCodigo(IdentityUser.UserCode), PoolDbCommand.PoolDbCommandResultType.Query)
            ObjPool.Pooling(Nothing, ldr, True)
            ObjUsuario = Nothing
            While ldr(0).Read
                If Escuela <> ldr(0).Item("cUniOrgNombre").ToString Then
                    DivPrincipal.Append("<tr style='color:#FFFFFF'>")
                    DivPrincipal.Append("   <td style='font-size:12px;color:#000000; text-align:left;font-weight :bold' colspan='3'><img src='../Imagenes/Ok2.gif' />" + ldr(0).Item("cUniOrgNombre").ToString + "</td><tr><td></td></tr>")
                    DivPrincipal.Append("</tr>")
                End If

                DivPrincipal.Append("<tr>")
                DivPrincipal.Append("   <td style='padding-left: 5%; text-align:left; font-size:10px;width:50%;'>" + ldr(0).Item("Fecha").ToString + "</td>")
                DivPrincipal.Append("   <td style='font-size:10px;width:25%;'>E: " + ldr(0).Item("HorIni").ToString + "</td>")
                DivPrincipal.Append("   <td style='font-size:10px;width:25%;'>S: " + ldr(0).Item("HorFin").ToString + "</td>")
                DivPrincipal.Append("</tr>")

                Escuela = ldr(0).Item("cUniOrgNombre").ToString                
            End While
            Using Seguridad As New BLL_Administracion
                Seguridad.Set_Transaccion_Insert(Nothing, 100401, IdentityUser.UserCode, My.Request.UserHostAddress.ToString, CrearXMLTransaccion("Consulta Pagina Movil", "/Pagina|" + My.Request.Url.Segments(My.Request.Url.Segments.Length - 1).ToString))
            End Using
        End Using

        DivPrincipal.Append("</table>")
        lblHorario.Text = DivPrincipal.ToString
    End Sub
End Class
